package com.qf.netty.utils;

import com.qf.netty.entity.Rooms;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 房间的管理类
 * author Ken
 * create_time 2023/1/5
 */
public class RoomUtils {

    private static Map<Integer, Rooms> roomsMap = new ConcurrentHashMap<>();

    /**
     * 添加房间
     * @param rooms
     */
    public static void addRooms(Rooms rooms){
        roomsMap.put(rooms.getRoomId(), rooms);
    }

    /**
     * 根据房间号，获取房间
     * @param roomId
     * @return
     */
    public static Rooms getRooms(Integer roomId){
        return roomsMap.get(roomId);
    }

    /**
     * 移除房间
     */
    public static void removeRooms(Integer roomId){
        roomsMap.remove(roomId);
    }
}
